<template>
  <div class="outer">
    <div class="box">
      <header class="header fix">
        <a href="javascript:;" class="backImg" @click="back"></a>
        <div class="dateTitle">
         选返程:{{$store.state.flight.back}}--{{$store.state.flight.go}}
        </div>
      </header>
      <div class="return-way" v-if="toFlightData!==''" @click="changeShow=true">
        <span class="icons-qu">去</span>
        <span>{{flight.month}}月{{flight.day}}日({{flight.Sunday}})</span>
        <span>{{flight.flightShowDetail[flight.index].fromTime}}</span>
        <span>--{{flight.flightShowDetail[flight.index].toTime}}</span>
        <span>{{flight.flightShowDetail[flight.index].fromInfo}}</span>
      </div>
      <date-toggle-tab :calendarArr="calendarArr"
                       @selectCalendar="dateShow = true"
                       @changeCalendar="weelSel"></date-toggle-tab>
      <div class="travelPolicy fix" :class="{positiontop:toFlightData!==''}">
        <label for="travelPolicy" class="label ">仅显示符合差旅标准的航班</label>
        <input id="travelPolicy" type="checkbox" v-model="$store.state.flightBack.travelPolicyCheck" @click="travelPolicyClick($event)" />
      </div>
      <div class="noFlight" v-if="noFlight">{{noFlightInfo}}</div>
    </div>
    <div class="main" :class="noFlight ? 'main-height' : 'no-main-height'">
      <scroll :data="$store.state.flightBack.flightShowDetail" style="position: absolute;top: 0;left: 0;right: 0;bottom: 0">
        <div>
          <ul class="content" v-if="noList" @click="outerClick">
            <li class="list" v-for="(item,index) in $store.state.flightBack.flightShowDetail"
                @click="flightListDetail(item,index)">
              <div class="listSub fix">
                <div class="liL">
                  <p class="startDate">{{item.fromTime}}</p>
                  <p>{{item.fromInfo}}</p>
                </div>
                <div class="liLine">

                </div>
                <div class="liM">
                  <p class="toDate">{{item.toTime}}</p>
                  <p>{{item.toInfo}}</p>
                </div>
                <div class="liR">
                  <p class="money"><span class="moneyIco">¥</span>{{item.lowestPrice}}</p>
                  <p v-if="item.restSeatNum>=9" class="Ticket">有票</p>
                  <p v-if="item.restSeatNum<9" class="Ticket">剩{{item.restSeatNum}}张</p>
                </div>
              </div>
              <div class="flightType fix">
                <span class="carrierInfo">{{item.carrierInfo}}&nbsp;&nbsp;|&nbsp;&nbsp;{{item.aircraftInfo}}</span>
                <span v-if="item.withinTwoHoursLowestPrice" class="lowPrice">低价</span>
              </div>
            </li>
          </ul>
        </div>
      </scroll>
    </div>
    <footer>
      <mt-tabbar v-model="selected1" :fixed="true">
        <mt-tab-item id="排序" @click.native="popupVisible1 = true" size="large">
          <i slot="icon" class="iconfont icon-jiage"></i>
          排序
        </mt-tab-item>
        <mt-tab-item id="舱位" @click.native="popupVisible2 = true" size="large">
          <i slot="icon" class="iconfont icon-zuoyiseat"></i>
          舱位
        </mt-tab-item>
        <mt-tab-item id="综合筛选" @click.native="popupVisible3 = true" size="large">
          <i slot="icon" class="iconfont icon-screen"></i>
          综合筛选
        </mt-tab-item>
      </mt-tabbar>
    </footer>
    <!--飞机出发查看详情弹窗-->
    <mt-popup v-model="changeShow" position="bottom" class="changePop">
      <div class="ticketDetail fix">
        <div class="titleDate"><span class="icons-qu">去</span>{{flight.month}}月{{flight.day}}日 {{flight.Sunday}}</div>
        <div class="fix">
          <div class="title1 fix">
            <p class="titleGoDate">
              {{flight.flightShowDetail[flight.index].fromTime}}
            </p>
            <p class="titleLineMiddle"></p>
            <p class="titleBackDate">
              {{flight.flightShowDetail[flight.index].toTime}}
            </p>
          </div>
          <div class="title2 fix">
            <p class="titleGoCity">
              {{flight.flightShowDetail[flight.index].fromInfo}}
            </p>
            <p class="flightDuration">
              {{flight.flightShowDetail[flight.index].costTime}}
            </p>
            <p class="titleBackCity">
              {{flight.flightShowDetail[flight.index].toInfo}}
            </p>
          </div>
          <div class="title3 fix">
            <p class="titleGoType">
              {{flight.flightShowDetail[flight.index].carrierInfo}}
            </p>
            <p class="titleLineInfo">
              {{flightTypeArr[flight.flightShowDetail[flight.index].aircraftDto.type]}}
            </p>
            <p class="titleBackType" v-show="flight.flightShowDetail[flight.index].mealType != ''">
              <i class="iconfont icon-tangshi"></i>
            </p>
          </div>
        </div>
      </div>
    </mt-popup>
    <mt-popup v-model="popupVisible1 " position="bottom">
      <div v-for="(pop,index) in popInfo" class="popItem" :class="{activePop:pop.isSelected}" @click="popActive(index)">
        {{pop.name}}<i class="iconfont icon-duihao r" v-show="pop.popShowCheck"></i>
      </div>
    </mt-popup>
    <mt-popup v-model="popupVisible2 " position="bottom">
      <div v-for="(pop,index) in popInfo1" class="popItem" :class="{activePop:pop.isSelected}"
           @click="popActive1(index)">
        {{pop.name}}<i class="iconfont icon-duihao r" v-show="pop.popShowCheck"></i>
      </div>
    </mt-popup>
    <mt-popup v-model="popupVisible3" position="bottom">
      <div class="filterBox fix">
        <div class="showSel">
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[0].tabInfos" v-show="tabInfo.a" @click="buxian(0,index)">
            <span class="showSelItem1">起飞</span><span class="showSelItem2 ell">{{tabInfo.listName}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[1].tabInfos" v-show="tabInfo.a" @click="buxian(1,index)">
            <span class="showSelItem1">出发</span><span class="showSelItem2 ell">{{tabInfo.fromAirport}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[2].tabInfos" v-show="tabInfo.a" @click="buxian(2,index)">
            <span class="showSelItem1">到达</span><span class="showSelItem2 ell">{{tabInfo.toAirport}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[3].tabInfos" v-show="tabInfo.a" @click="buxian(3,index)">
            <span class="showSelItem1">机型</span><span class="showSelItem2 ell">{{tabInfo.aircrefTypeName}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[4].tabInfos" v-show="tabInfo.a" @click="buxian(4,index)">
            <span class="showSelItem1">航司</span><span class="showSelItem2 ell">{{tabInfo.carrierName}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
        </div>
        <div class="empty" @click="emptySel">
          清空筛选
        </div>
      </div>
      <div class="tabBox fix">
        <div class="tab">
          <div class="tabItem"  :class="{activeTabItem:tab.istab}"  v-for="(tab,index) in tabs" @click="tabSel(index)">{{tab.name}}</div>
        </div>
        <div class="tabInfo">
          <!--起飞时间-->
          <div class="tabInfoItem"  v-show="a">
            <label v-for="(tabInfo,index) in tabInfo[0].tabInfos" @click="buxian(0,index)">
              <span class="tabInfoSubL">{{tabInfo.listName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--出发机场-->
          <div class="tabInfoItem"  v-show="b">
            <label v-for="(tabInfo,index) in tabInfo[1].tabInfos" @click="buxian(1,index)">
              <span class="tabInfoSubL">{{tabInfo.fromAirport}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--到达机场-->
          <div class="tabInfoItem"  v-show="c">
            <label v-for="(tabInfo,index) in tabInfo[2].tabInfos" @click="buxian(2,index)">
              <span class="tabInfoSubL">{{tabInfo.toAirport}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--机型-->
          <div class="tabInfoItem"  v-show="d">
            <label v-for="(tabInfo,index) in tabInfo[3].tabInfos" @click="buxian(3,index)">
              <span class="tabInfoSubL">{{tabInfo.aircrefTypeName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--航空公司-->
          <div class="tabInfoItem"  v-show="e">
            <label v-for="(tabInfo,index) in tabInfo[4].tabInfos" @click="buxian(4,index)">
              <span class="tabInfoSubL">{{tabInfo.carrierName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
        </div>
      </div>
      <div class="queren" @click="queren">
        确认
      </div>
    </mt-popup>
    <date @dateClick="dateClick" @dateBack="dateBack" v-show="dateShow" :max="max" :openTime="openTime" tipDivText="返程" :min="min" backCustom="1"></date>
    <toast  :toastInfo="toastInfo"></toast>
  </div>
</template>

<script>
  import { Navbar, TabItem ,Tabbar,Indicator} from 'mint-ui';
  import date from 'components/date.vue';
  import dateToggleTab from 'components/flight/date-toggle-tab.vue'
  import toast from 'components/toast.vue';
  import alert1 from 'components/alert.vue'
  import Scroll from "../../../common/scroll/scroll.vue"

  export default{
    data(){
      return {
        flightTypeArr:['','小型机','中型机','大型机'],
        dateShow:false,
        a: true,
        b: false,
        c: false,
        d: false,
        e: false,
        selected1: '排序',//底部tab切换默认高亮
        popupVisible1: false,//底部上升  排序
        popupVisible2: false,//底部上升  舱位
        popupVisible3: false,//底部上升  综合筛选
        isActive: false,
        flightListForm: [],
        noList:true,
        changeShow:false,/*查看详情弹窗*/
        toflightType:'',//去时的机型
        food:false,
        tomonth:'',//去的时间
        today:'',
        toAirportName:'',//出发的机场name
        toport:'',  //去的机场名的后缀
        todestination:'',  //到达的目的地
        toneedTime:'', //去时所用的时
        togotime:'', //去出发的时间
        togettime:'', //去到达的时间
        updateTime:0,//定时初始值
        IntervalTime:'',//定时器
        toastInfo:'',
        checkPriceRouteRuleItemId:null,//验价后的路由
      }
    },
    components: {Navbar, TabItem, Tabbar, date,alert:alert1,toast, dateToggleTab,Scroll},
    beforeRouteLeave (to, from, next) {
      clearInterval(this.IntervalTime);
      next();

    },
    methods: {
      outerClick(){
        if(this.updateTime >= 480){
          this.toastInfo = '操作超时,正在为您跟新航班列表';
          this.flightAjax();
        }
      },
      update(){
        var that = this;
        clearInterval(that.IntervalTime);
        that.updateTime = 0;
        that.toastInfo = '';

        this.IntervalTime = setInterval(function () {
          if(that.updateTime >= 480){
            clearInterval(that.IntervalTime);
          }else{
            that.updateTime++
          }
        },1000)
      },
      format(date, fmt) { //用来处理时间
        var o = {
          "M+": date.getMonth() + 1, //月份
          "d+": date.getDate(), //日
          "h+": date.getHours(), //小时
          "m+": date.getMinutes(), //分
          "s+": date.getSeconds(), //秒
          "q+": Math.floor((date.getMonth() + 3) / 3), //季度
          "S": date.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
          if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
      }, //返回一个日期格式
      dateBack(){this.dateShow = false;},
      dateClick(msg){
        this.dateShow = false;
        this.date = msg;
        this.$store.state.flight.returnTimes = msg;
        this.$store.state.flightBack.month = msg.substring(5, 7);
        this.$store.state.flightBack.day = msg.substring(8, 10);
        this.$store.state.flightBack.Sunday = msg.weekGet();
        this.flightAjax({date: 1});
      },
      travelPolicyClick(e){
        this.$store.state.flightBack.travelPolicyCheck = e.target.checked;
        this.flightAjax();
      },
      buxian(k, index){
        //控制样式
        var arr = this.$store.state.flightBack.tabInfo[k].tabInfos;
        var errorNum = arr.length;
        if (index == 0) {
          for (var i = 1; i < arr.length; i++) {
            arr[i].a = false;
          }
          arr[0].a = true;
        } else {

          arr[index].a = !arr[index].a;

          for (var k = 0; k < arr.length; k++) {
            if (arr[k].a == false) {
              errorNum--;
              if (errorNum == 0) {
                arr[0].a = true;
              }
            } else {
              arr[0].a = false;
            }
          }
        }
      },//综合筛选单个点击
      queren(){
        var flightBack = this.$store.state.flightBack;
        flightBack.fromTimes = '';
        flightBack.fromAirportNames = '';
        flightBack.toAirportNames = '';
        flightBack.aircrafts = '';
        flightBack.carrierNameShorts = '';

        var arr0 = this.tabInfo[0].tabInfos;  // 起飞时间0
        if (arr0[0].a == true) {
          flightBack.fromTimes = '';
        } else {
          for (var i = 0; i < arr0.length; i++) {
            if (arr0[i].a == true) {
              flightBack.fromTimes += arr0[i].listName + ','
            }
          }
        }
        flightBack.fromTimes = this.fromTimes.substring(0, this.fromTimes.length - 1);

        var arr1 = this.tabInfo[1].tabInfos;  //出发机场1
        if (arr1[0].a == true) {
          flightBack.fromAirportNames = '';
        } else {
          for (var i = 0; i < arr1.length; i++) {
            if (arr1[i].a == true) {
              flightBack.fromAirportNames += arr1[i].fromAirport + ','
            }
          }
        }
        flightBack.fromAirportNames = this.fromAirportNames.substring(0, this.fromAirportNames.length - 1);

        var arr2 = this.tabInfo[2].tabInfos;  //到达机场2
        if (arr2[0].a == true) {
          flightBack.toAirportNames = '';
        } else {
          for (var i = 0; i < arr2.length; i++) {
            if (arr2[i].a == true) {
              flightBack.toAirportNames += arr2[i].toAirport + ','
            }
          }
        }
        flightBack.toAirportNames = this.toAirportNames.substring(0, this.toAirportNames.length - 1);

        var arr3 = this.tabInfo[3].tabInfos; //机型3
        if (arr3[0].a == true) {
          flightBack.aircrafts = '';
        } else {
          for (var i = 0; i < arr3.length; i++) {
            if (arr3[i].a == true) {
              flightBack.aircrafts += arr3[i].aircrefType + ','
            }
          }
        }
        flightBack.aircrafts = this.aircrafts.substring(0, this.aircrafts.length - 1);

        var arr4 = this.tabInfo[4].tabInfos; //航空公司4
        if (arr4[0].a == true) {
          flightBack.carrierNameShorts = '';
        } else {
          for (var i = 0; i < arr4.length; i++) {
            if (arr4[i].a == true) {
              flightBack.carrierNameShorts += arr4[i].carrierName + ','
            }
          }
        }
        flightBack.carrierNameShorts = this.carrierNameShorts.substring(0, this.carrierNameShorts.length - 1);

        this.popupVisible3 = false;
        this.flightAjax();
      },//综合筛选点击
      emptySel(){
        for (var i = 0; i < this.tabInfo.length; i++) {
          for (var j = 1; j < this.tabInfo[i].tabInfos.length; j++) {
            this.$store.state.flightBack.tabInfo[i].tabInfos[j].a = false;
          }
          this.$store.state.flightBack.tabInfo[i].tabInfos[0].a = true;
        }
        var flightBack = this.$store.state.flightBack;
        flightBack.fromTimes = '';
        flightBack.fromAirportNames = '';
        flightBack.toAirportNames = '';
        flightBack.aircrafts = '';
        flightBack.carrierNameShorts = '';
      },
      goRouter(){
        var navItem = this.selected.charAt(this.selected.length - 1);
        switch (navItem) {

        };
        this.$store.state.flightBack.fromDate = this.$store.state.flightBack.week[navItem].fromDate;

        this.$store.state.flightBack.selected = navItem;

        this.$store.state.flightBack.Sunday = this.$store.state.flightBack.week[navItem].week;
        this.flightAjax();
      }, //重新选择了星期
      weelSel(index){
        var gg = Date.parse(this.$store.state.flightBack.week[index].fromDate);
        var kk = Date.parse(this.$store.state.flight.fromDate);
        if(gg<=kk){
          this.$vux.toast.show({
            type: 'text',
            text: '返程时间需要大于去程时间',
            time: 2500
          })
        }else{
          this.$store.state.flight.returnTimes = this.$store.state.flightBack.week[index].fromDate;
          this.flightAjax({date: 1});
        }
      }, //重新选择了星期
      back(){
        this.$router.go(-1);
      },
      flightListDetail(item,index){
        this.$store.state.flightBack.index = index;
        this.$store.state.flightBack.currentList = item;
        this.$router.push({
          path: 'backflightListDetail',
          query: {
            carrierCode: item.carrier.code,
            fromAirport: item.fromAirport,
            toAirport: item.toAirport
          }
        })
      },
      popActive(index){
        for (var i = 0; i < this.popInfo.length; i++) {
          this.$store.state.flightBack.popInfo[i].isSelected = false;
          this.$store.state.flightBack.popInfo[i].popShowCheck = false;
        }
        this.$store.state.flightBack.popInfo[index].isSelected = true;
        this.$store.state.flightBack.popInfo[index].popShowCheck = true;
        this.popupVisible1 = false;

        if (index == 0) {
          this.$store.state.flightBack.sort = 'price_down';
          this.flightAjax();
          ;
        }
        if (index == 1) {
          this.$store.state.flightBack.sort = 'date_early';
          this.flightAjax();
          ;
        }

      },//排序   点击
      popActive1(index){
        for (var i = 0; i < this.popInfo1.length; i++) {
          this.$store.state.flightBack.popInfo1[i].isSelected = false;
          this.$store.state.flightBack.popInfo1[i].popShowCheck = false;
        }
        this.$store.state.flightBack.popInfo1[index].isSelected = true;
        this.$store.state.flightBack.popInfo1[index].popShowCheck = true;
        this.popupVisible2 = false;

        switch (index) {
          case 0: //头等舱/公务舱
            this.$store.state.flightBack.code = 'C,F';
            this.flightAjax();
            break;
          case 1://经济舱
            this.$store.state.flightBack.code = 'Y';
            this.flightAjax();
            break;
          case 2: //不限
            this.$store.state.flightBack.code = '';
            this.flightAjax();
            break;
        }


      },//舱位  点击
      tabSel(index){
        for (var i = 0; i < this.tabs.length; i++) {
          this.tabs[i].istab = false;
        }
        this.tabs[index].istab = true;
        this.a = false;
        this.b = false;
        this.c = false;
        this.d = false;
        this.e = false;
        switch (index) {
          case 0:
            this.a = true;
            break;
          case 1:
            this.b = true;
            break;
          case 2:
            this.c = true;
            break;
          case 3:
            this.d = true;
            break;
          case 4:
            this.e = true;
            break;
        }
      },
      shuju(){
        var that = this;
        var state = this.$store.state;
        //        请求成功之前就有值,请求成功之后再对比.  还存在则显示.
        var fromTime = state.flightBack.fromTimes.split(',');
        var fromAirportNames = state.flightBack.fromAirportNames.split(',');
        var toAirportNames = state.flightBack.toAirportNames.split(',');
        var aircrafts = state.flightBack.aircrafts.split(',');
        var carrierNameShorts = state.flightBack.carrierNameShorts.split(',');


        //综合筛选初始化
        state.flightBack.tabInfo = [
          {
            tabInfos: [
              {
                listName: '不限',
                a: true
              },
              {
                listName: '00:00-06:00',
                a: false
              },
              {
                listName: '06:00-12:00',
                a: false
              },
              {
                listName: '12:00-18:00',
                a: false
              },
              {
                listName: '18:00-24:00',
                a: false
              },

            ]
          },//起飞时间
          {
            tabInfos: [
              {
                fromAirport: '不限',
                a: true
              },
            ]
          },//出发机场
          {
            tabInfos: [
              {
                toAirport: '不限',
                a: true
              },
            ]
          },//到达机场
          {
            tabInfos: [
              {
                aircrefTypeName: '不限',
                aircrefType: '',
                a: true
              },
            ]
          },//机型
          {
            tabInfos: [
              {
                carrierName: '不限',
                a: true
              },
            ]
          }//航空公司
        ];
        //综合筛选数据重组
        for (var i = 0; i < state.flightBack.tabInfo.length; i++) {
          switch (i) {
            case 0://起飞时间
              if (fromTime[0] != '') {
                for (var k = 0; k < fromTime.length; k++) {
                  for (var j = 0; j < state.flightBack.tabInfo[i].tabInfos.length; j++) {
                    if (fromTime[k] == state.flightBack.tabInfo[i].tabInfos[j].listName) {
                      state.flightBack.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flightBack.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 1: //出发机场
              for (var j = 0; j < state.flightBack.fromCityForms.length; j++) {
                var obj = {};
                obj.fromAirport = state.flightBack.fromCityForms[j].fromAirport;
                obj.a = state.flightBack.fromCityForms[j].checked;
                state.flightBack.tabInfo[i].tabInfos.push(obj);
              }
              if (fromAirportNames[0] != '') {
                for (var k = 0; k < fromAirportNames.length; k++) {
                  for (var j = 0; j < state.flightBack.tabInfo[i].tabInfos.length; j++) {
                    if (fromAirportNames[k] == state.flightBack.tabInfo[i].tabInfos[j].fromAirport) {
                      state.flightBack.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flightBack.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 2:  //到达机场
              for (var j = 0; j < state.flightBack.toCityForms.length; j++) {
                var obj = {};
                obj.toAirport = state.flightBack.toCityForms[j].toAirport;
                obj.a = state.flightBack.toCityForms[j].checked;
                state.flightBack.tabInfo[i].tabInfos.push(obj);
              }
              if (toAirportNames[0] != '') {
                for (var k = 0; k < toAirportNames.length; k++) {
                  for (var j = 0; j < state.flightBack.tabInfo[i].tabInfos.length; j++) {
                    if (toAirportNames[k] == state.flightBack.tabInfo[i].tabInfos[j].toAirport) {
                      state.flightBack.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flightBack.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 3:  //机型
              for (var j = 0; j < state.flightBack.aircraftTypes.length; j++) {
                var obj = {};
                obj.aircrefTypeName = state.flightBack.aircraftTypes[j].aircrefTypeName;
                obj.aircrefType = state.flightBack.aircraftTypes[j].aircrefType;
                obj.a = false;
                state.flightBack.tabInfo[i].tabInfos.push(obj);
              }
              if (aircrafts[0] != '') {
                for (var k = 0; k < aircrafts.length; k++) {
                  for (var j = 0; j < state.flightBack.tabInfo[i].tabInfos.length; j++) {
                    if (aircrafts[k] == state.flightBack.tabInfo[i].tabInfos[j].aircrefType) {
                      state.flightBack.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flightBack.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 4:  //航空公司
              for (var j = 0; j < state.flightBack.carrierForms.length; j++) {
                var obj = {};
                obj.carrierName = state.flightBack.carrierForms[j].carrierName;
                obj.a = false;
                state.flightBack.tabInfo[i].tabInfos.push(obj);
              }
              if (carrierNameShorts[0] != '') {
                for (var k = 0; k < carrierNameShorts.length; k++) {
                  for (var j = 0; j < state.flightBack.tabInfo[i].tabInfos.length; j++) {
                    if (carrierNameShorts[k] == state.flightBack.tabInfo[i].tabInfos[j].carrierName) {
                      state.flightBack.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flightBack.tabInfo[i].tabInfos[0].a = false;
              }
              break;
          }
        }
      },
      flightAjax(key){
        this.noList = false;
        var key = key || '';
        var that = this;
        var state = this.$store.state;
        var flightBack = this.$store.state.flightBack;
        if(!that.toastInfo){
          that.$vux.loading.show({
            text: '加载中...'
          })
        }
        that.updateTime = 0;

        that.$flight.getFlightList({
          fromCityCode: state.flight.toCityCode,//到达城市code
          toCityCode: state.flight.fromCityCode,//出发城市code
          fromCityId: state.flight.toCityId,//出发城市id
          toCityId: state.flight.fromCityId,//到达城市id
          fromDate: state.flight.returnTimes,//出发日期
          sort: state.flightBack.sort,//时间和价格排序方式  默认为从早到晚:date_early 价格从低到高price_down
          code: state.flightBack.code,//F:头等舱   C:公务舱     Y:经济舱
          isFilter: state.flightBack.travelPolicyCheck,//差旅政策航班是否勾选

          fromType: this.$store.state.flight.toType,
          toType: this.$store.state.flight.fromType,

          fromTimes: state.flightBack.fromTimes,//出发时间点
          fromAirportNames: state.flightBack.fromAirportNames,//出发机场
          toAirportNames: state.flightBack.toAirportNames,//达到机场
          aircrafts: state.flightBack.aircrafts,//机型
          carrierNameShorts: state.flightBack.carrierNameShorts,//航空公司
        },function (res) {
          that.$vux.loading.hide();
          clearInterval(that.IntervalTime);
          that.update();//启动定时器
          //拼接几月几号星期几
          flightBack.month = that.flight.returnTimes.substring(5,7);
          flightBack.day = that.flight.returnTimes.substring(8,10);

          state.flightBack.productGroupMap = res.ProductGroupMap; // 列表详情数据标题

          if (key.date == 2 || key.date == 1) { //如果点击了星期 或者点击了日期控件
            state.flightBack.fromCityForms = res.fromCityForms;//           出发机场
            state.flightBack.toCityForms = res.toCityForms;//           到达机场
            state.flightBack.aircraftTypes = res.aircraftTypes;//           机型
            state.flightBack.carrierForms = res.carrierForms;//           航空公司
            state.flightBack.cabinTypeMap = res.cabinTypeMap;//           折扣转换
            state.flightBack.cabinGradeMap = res.cabinGradeMap;//           舱位转换
            that.shuju();//综合筛选数据处理
            state.flightBack.week = res.week; //星期列表
            for (var i = 0; i < state.flightBack.week.length; i++) {
              if (state.flightBack.week[i].flag == true) {
                state.flightBack.Sunday = '周' + state.flightBack.week[i].week;
              }
            }
            that.selected = that.$store.state.flightBack.selected;
          }

          if(res.code=== '0' || res.code=== '2' ){//查询返回数据为空 0  查询异常  2
            that.$store.state.flightBack.noFlight = true;
            that.$store.state.flightBack.noFlightInfo = res.message;
            alert(that.noFlightInfo);
            that.noList = false;
          }else if(res.code=== '1' || res.code=== '8'){ //根据差旅政策过滤后为空 1
            that.$store.state.flightBack.noFlight = true;
            that.$store.state.flightBack.noFlightInfo = res.message;
            that.noList = true;
            state.flightBack.flightShowDetail = res.flightListForm[0].flightShowDetail;  //详细   所有航班列表
            state.flightBack.flightForm = res.flightListForm[0].flightForm;//验价需要的数据
            that.shuju();//综合筛选数据初始化，第一次进页面用
          }else{
            that.$store.state.flightBack.noFlight = false;
            that.noList = true;
            state.flightBack.flightShowDetail = res.flightListForm[0].flightShowDetail;  //详细   所有航班列表
            state.flightBack.flightForm = res.flightListForm[0].flightForm;//验价需要的数据
            that.shuju();//综合筛选数据初始化，第一次进页面用
          }
        },function (err) {
          that.$vux.loading.hide();
          that.$router.push({
            name:'error'
          })
        });
      }
    },
    created(){

    },
    mounted(){
      this.update();
      if (this.$route.params.from == 'toflightListDetail') {
        var flightBack = this.$store.state.flightBack;
        flightBack.fromTimes = '';
        flightBack.fromAirportNames = '';
        flightBack.toAirportNames = '';
        flightBack.aircrafts = '';
        flightBack.carrierNameShorts = '';
        flightBack.sort = 'date_early';
        this.$store.state.flightBack.travelPolicyCheck=true;
      }
      this.flightAjax({date: 1});
      //      综合筛选样式数据初始化
      for (var i = 0; i < this.tabs.length; i++) {
        this.$store.state.flightBack.tabs[i].istab = false;
      }
      this.$store.state.flightBack.tabs[0].istab = true;
    },
    watch: {},
    computed: {
      calendarArr() {
        return this.$store.state.flightBack.week;
      },
      openTime(){
        return this.$store.state.flight.returnTimes
      },
      min(){
        return this.$store.state.flight.fromDate.futureOrPast(1)
      },
      max(){
        return '365'.future()
      },
      fromTimes(){
        return this.$store.state.flightBack.fromTimes;
      }, //出发时间参数
      fromAirportNames(){
        return this.$store.state.flightBack.fromAirportNames;
      },//出发机场参数
      toAirportNames(){
        return this.$store.state.flightBack.toAirportNames;
      },//到达机场参数
      aircrafts(){
        return this.$store.state.flightBack.aircrafts;
      },//机型参数
      carrierNameShorts(){
        return this.$store.state.flightBack.carrierNameShorts;
      },//航空公司参数
      flightBack(){
        return this.$store.state.flightBack
      },
      flight(){
        return this.$store.state.flight
      },
      popInfo(){
        return this.$store.state.flightBack.popInfo;
      },
      popInfo1(){
        return this.$store.state.flightBack.popInfo1;
      },
      noFlight(){
        return this.$store.state.flightBack.noFlight;
      },
      noFlightInfo(){
        return this.$store.state.flightBack.noFlightInfo;
      },
      tabs(){
        return this.$store.state.flightBack.tabs;
      },
      tabInfo(){
        return this.$store.state.flightBack.tabInfo;
      },
      travelPolicyCheck(){
        return this.$store.state.flightBack.travelPolicyCheck;
      },
      toFlightData(){
        return this.$store.state.flight.toFlightData
      }// 去程数据展示
    }
  }
</script>

<!--没有符合条件的航班-->
<style scoped>
  .noFlight{
    display: flex;
    padding: 0 .5rem;
    text-align: left;
    height: 2rem;
    background-color: #efefef;
    align-items: center;
  }
</style>
<!--自定义头-->
<style scoped>
  .header {
    background: #46a1bb;
    height: 2.2rem;
    background-size: cover;
    color: #fff;
    padding: 0 .75rem;
    width: 100%;
    box-sizing: border-box;
    display: flex;
  }
  .backImg {
    flex: 0 0 15%;
    height: 2.2rem;
    line-height: 2.2rem;
    text-align: left;
    background: url('../../../assets/images/back.png') no-repeat left center;
    background-size: .6rem 1.1rem;
  }
  .dateTitle {
    flex:  0 0 70%;
    height: 2.2rem;
    text-align: center;
    line-height: 2.2rem;
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .content{
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
  }
</style>
<!--综合筛选-->
<style scoped>
  /*筛选结果*/
  .empty{
    height: 1rem;
    line-height: 1rem;
    color: #46a1bb;
    font-size: .75rem;/*px*/
    float: right;
    margin-bottom: .5rem;
    margin-top: .5rem;
    margin-right: 1.5%;
  }
  .filterBox{
    border-top: 1px solid #ddd;
    padding: .25rem .45rem  0 .45rem;
  }
  .showSel{
    overflow: auto;
  }
  .showSelItem{
    border: 1px solid #46a1bb;/*no*/
    width: 47%;
    height: 1.4rem;
    line-height: 1.4rem;
    color: #46a1bb;
    font-size: .75rem;/*px*/
    float: left;
    box-sizing: border-box;
    margin: .25rem 1.5%  0;
  }
  .showSelItem1{
    float: left;
    margin-left: .25rem;
    margin-right: .25rem;
  }
  .showSelItem2{
    float: left;
  }
  .showSelItem3{
    float: right;
    margin-right: .25rem;
  }
  /*筛选条件*/
  .tabBox{
    border-top: 1px solid #ddd;/*no*/
    display: flex;
  }
  .queren{
    height: 2.5rem;
    width: 100%;
    background-color: #46a1bb;
    text-align: center;
    line-height: 2.5rem;
    color: #fff;
    font-size: .9rem;/*px*/
  }

  .mint-popup-bottom {
    width: 100%;
  }
  .tab {
    flex: 0 0 40%;
    font-size: .75rem;/*px*/
  }
  .tabInfo {
    flex: 0 0 60%;
    height: 12.5rem;
    overflow: auto;
  }
  .tabInfoSubL {
    font-size: .75rem;/*px*/
    margin-left: 1.2rem;
  }
  .tabInfoSubR {
    float: right;
    width: .75rem;
    height: .75rem;
    margin: .75rem 2rem;
    border: 1px solid #46a1bb;/*no*/
  }
  .tabInfoSubR1 {
    float: right;
    width: .75rem;
    height: .75rem;
    margin: 0px 2rem;
    font-size: .75rem;/*px*/
    color: #46a1bb;
  }
  .tabItem {
    height: 2.5rem;
    line-height: 2.5rem;
    width: 6.75rem;
    background-color: #fff;
    text-align: center;
    border-bottom: 1px solid #ddd;/*no*/
    border-right: 1px solid #ddd;/*no*/
  }
  .tab .activeTabItem{
    background-color: #46a1bb;
    color: #fff;
    border-right: none;
  }
  .tabInfoItem {
    height: 2.5rem;
    line-height: 2.5rem;
    width: 12rem;

  }
  .tabInfoItem label{
    width: 100%;
    height: 100%;
    display: block;
    margin: auto;
    border-bottom: 1px solid #ddd;/*no*/
  }
</style>
<style scoped>
  .popItem {
    line-height: 2.5rem;
    width: 100%;
    border-bottom: 1px solid #ddd;/*no*/
    font-size: .75rem; /*px*/
    box-sizing: border-box;
    padding: 0 1.2rem;
  }
  .activePop {
    color: #46a1bb;
  }
</style>

<style scoped>
  .carrierInfo{
    padding: .25rem 0;
    float: left;
  }

  .lowPrice{
    background-color:#f60;
    color: #fff;
    float: right;
    padding: .25rem;
    border-radius: .2rem;
  }

  .box {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
  }

  .flightType {
    margin-top: .2rem;
  }


  .money {
    color: #f60;
    text-align: right;
    font-size: .9rem; /*px*/
    margin-bottom: .2rem;
  }
  .Ticket{
    text-align: right;
    color: #f60;
  }
  .moneyIco{
    font-size: .65rem;/*px*/
  }

  .startDate {
    font-size: .9rem; /*px*/
    margin-bottom: .4rem;
    color: #333;
  }

  .toDate{
    font-size: .9rem; /*px*/
    margin-bottom: .4rem;
    color: #333;
  }

  .list {
    padding: .75rem .75rem;
    color: #999;
    border-bottom: 1px solid #eee;/*no*/
  }

  .liL {
    width: 5.75rem;
    text-align: left;
  }

  .listSub .liR {
    float: right;
  }

  .liM {
    text-align: right;
  }
  .listSub {
    display: flex;
  }
  .listSub>div {
    flex: 1;
  }

  .liLine {
    flex: 0 0 2.25rem!important;
    height: .25rem;
    background: url("../../../assets/images/goBackLine90.png") no-repeat;
    margin: .75rem .125rem;
    background-size: cover;
  }

  .listSub > div {
    float: left;
  }

  .outer {
    width: 100%;
    position: relative;
    background-color: #fff;
    height: 100%;
    font-size: .6rem;
    overflow: hidden;
  }
  .main {
    position: relative;
    background-color: #fff;
    overflow: hidden;
  }
  .main-height {
    height: calc(100% - 11.7rem);
    margin-top: 9.2rem;
  }
  .no-main-height {
    height: calc(100% - 9.7rem);
    margin-top: 7.2rem;
  }
  .title {
    color: #fff;
    background-color: #0d496b;
    padding: .25rem .75rem .25rem;
    height: 2rem;
  }
  .dateTab {
    float: left;
    width: 88%;
  }
  .dateTab .container {
    width: 95%;
    display: flex;
  }
  .itemDate {
    flex: 1;
    text-align: center;
    padding: .25rem 0;
    border-radius: .25rem;
    font-size: .6rem;/*px*/
  }

  .itemDateNum {
    margin-top: .25rem;
  }

  .dateImg {
    color: #3e3a39;
    float: right;
    width: 10%;
    text-align: center;
    height: 1.75rem;
    background: url("../../../assets/images/calendar.png") no-repeat center center;
    background-size: 1.05rem 1.15rem ;
  }


</style>

/*ticketDetail*/
<style scoped>
  .ticketDetail {
    text-align: center;
    background-color: #fff;
    border-radius: .125rem;
  }

  .titleDate {
    font-size: .75rem; /*px*/
    text-align: left;
    padding: .65rem .5rem;
  }

  .title1 {
    display: flex;
    width: 100%;
    line-height: 1.5rem;
    font-size: 1.15rem; /*px*/
  }

  .title1 p {
    flex: 1;
  }

  .title2 {
    line-height: 1.25rem;
  }

  .title3 {
    line-height: 1.25rem;
  }

  .titleGoDate {
    width: 4.5rem;
    margin-left: 1.5rem;
  }

  .titleBackDate {
    width: 4.5rem;
    margin-right: 1.5rem;
  }
  .titleLineMiddle {
    width: 6.25rem;
    height: 1.5rem;
    background: url("../../../assets/images/goBackLine.png") no-repeat center;
    background-size: 5.65rem .25rem;
  }
  .titleGoCity {
    width: 5.65rem;
    float: left;
    margin-left: .5rem;
  }
  .flightDuration{
    float: left;
    width: 4.25rem;
    text-align: center;
  }
  .titleBackCity {
    width: 5.65rem;
    float: right;
    margin-right: .5rem;
  }
  .titleGoType {
    width: 7rem;
    float: left;
    margin-left: 10px;
  }
  .titleLineInfo {
    float: left;
    width: 3.75rem;
  }
  .titleBackType {
    width: 7rem;
    float: right;
    margin-right: .25rem;
  }

</style>


<!--底部tab-->
<style scoped>
  .iconfont {
    font-size: .9rem; /*px*/
  }

  footer {
    height: 2.5rem;
    position: fixed; /*不加固定定位是block加高度的,会把父级撑开.加了之后脱离文档流*/
    right: 0;
    bottom: 0;
    left: 0;
  }

  footer .mint-tabbar {
    height: 2.5rem;
    font-weight: bold;
  }

  footer .mint-tab-item {
    padding: .375rem 0;
  }
  footer .mint-tab-item-label {
    font-size: .55rem; /*px*/
    margin-top: .25rem;
  }
  footer .mint-tabbar > .mint-tab-item.is-selected {
    color: #46a1bb;
  }
.mint-tab-item-icon {
  margin:  0 auto!important;
}
  footer .mint-tab-item-icon {
    width: .9rem;
    height: .925rem;
    margin: 0 auto!important;
  }
  .mint-navbar .mint-tab-item {
    padding: .25rem 0;
    font-size: .6rem;/*px*/
  }
  .mint-navbar .mint-tab-item p {
    font-size: .6rem;/*px*/
  }
  .is-selected {
    border: none;
    background-color: #46a1bb;
    color: #fff;
    margin-bottom: 0;
  }
  .mint-navbar {
    background-color: #0d496b;
  }
  .return-way{
    background-color: #efefef;
    height: 2rem;
    width: 100%;
    line-height: 2rem;
    padding: 0 .5rem;
    z-index: 1000;
  }
  .changePop{
    width: 98.67%;
    margin: 0 auto 20rem;
    height: 5rem;
  }
  .poplist{
    width: 100%;
    height: 5rem;
    padding-top: .5rem;
  }
  .poplist span{
    display: inline-block;
    height: .75rem;
    width: 2.5rem;
    float: left;
  }
  .L{
    width: 5.75rem;
    text-align: left;
    margin-left: .75rem;
  }
  .L >p{
    margin-top: .375rem;
    text-align: center;
  }
  .M{
    width: 5.25rem;
    padding-left: .5rem;
    text-align: center;
  }
  .M >.liLine {
    width: 3rem;
    height: .25rem;
    background: url("../../../assets/images/goBackLine90.png") no-repeat;
    /* margin: .75rem 5px;*/
    margin-top: .5rem;
    background-size: cover;
  }
  .R{
    float: right;
  }
  .R > P{
    margin-top: .375rem;
    text-align: center;
  }
  .line{

    margin-top: .25rem;
  }
  .poplist >div{
    float: left;
  }
  .p4{
    margin-left: -1.5rem;
  }
  .p2{padding: 0}
  .p5{
    text-align: left;
    margin-left: .5rem;
    padding: 0 !important;
  }
  .p1{margin-top: 0 !important;}
  .p6{margin-top: 0 !important;}
</style>



<!--仅显示符合差旅标准的航班-->
<style scoped>
  .travelPolicy{
    padding: 0 .75rem;
    border-bottom: 1px solid #ddd;/*no*/
    line-height: 2rem;
    height: 2rem;
    font-size: .7rem;
    display: flex;
    background-color: #fff;
    box-sizing: border-box;
  }

  .travelPolicy input[type=checkbox]{
    /*flex: 10%;*/
    height: .8rem;
    margin-top: .55rem;
    width:.8rem;
  }
  .icons-qu{
    background-color: #0c80ba;
    padding: .1rem;
    border-radius: .05rem;
    color: #FFFFFF;
  }
  #travelPolicy{
    flex:  0 0 10%;
  }
  .label{
    flex: 0 0 90%;
  }
  .positiontop{

  }
  .head-qu{
    padding-top: .5rem;
    padding-left: .5rem;
  }
  .head-span{
    font-size: .75rem;/*px*/
  }
</style>
